<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../style/css/user/center.css">
    <link rel="stylesheet" type="text/css" href="../../style/css/back/style.css">
    <script src="../../style/js/jquery-1.8.3.js" type="text/javascript"></script>
    <script src="../../style/js/ajaxfileupload.js"></script>
    <script type="text/javascript">
        $(function () {
            $.get("../../user/getUserComment", function (res) {
                    if (res.code === 500) {
                        alert(res.msg);
                    } else if (res.code === 202) {
                        alert("登录失效,请重新登录")
                    } else {
                        var str = ""
                        for (let i = 0; i < res.data.length; i++) {
                            str += "<tr align='center'>";
                            str += "<td id='numTd'>" + (i + 1) + "</td>"
                            str += "<td>" + res.data[i].newsTitle + "</td>"
                            str += "<td>" + res.data[i].content + "</td>"
                            str += "<td>" + (new Date(res.data[i].time)).toLocaleString() + "</td>"
                            if (res.data.pid===0){
                                str += "<td>此文章</td>"
                            }
                            str += "<td><a onclick='deleteComment(" + res.data[i].id + ")' href='javaScript:void(0)'>删除评论</a> "+
                                "<a onclick='deleteCollect(" + res.data[i].newsId + ")' href='javaScript:void(0)'>查看</a>"
                            str += "</tr>"
                        }
                        $("#collectTable").append(str);
                    }
                }
            )
        })

        function deleteComment(commentId){
                if (confirm("确定要删除该评论吗?")) {
                    $.get("../../user/deleteComment", {commentId:commentId}, function (res) {
                        if (res.code === 500) {
                            alert(res.msg);
                        } else if (res.code === 202) {
                            alert("登录失效,请重新登录")
                        } else {
                            location.reload();
                        }
                    })
                }
        }



    </script>
</head>
<body>
<div class="public_m1">
    <div class="public_m2">收藏管理</div>
    <!--数据列表 -->
    <table class="tablelist" id="collectTable"  style="width: 888px">
        <tr>
            <th>序号<i class="sort"></i></th>
            <th>新闻标题</th>
            <th>评论内容</th>
            <th>评论时间</th>
            <th>回复人昵称</th>
            <th>操作</th>
        </tr>
    </table>
</div>
</body>
</html>
